package de.listrong.da.ontology;

import com.hp.hpl.jena.ontology.DatatypeProperty;
import com.hp.hpl.jena.ontology.Individual;
import com.hp.hpl.jena.ontology.OntClass;
import com.hp.hpl.jena.ontology.OntModel;

import gate.Document;

import de.listrong.da.ontology.util.WriteToABox;
import de.listrong.da.tools.IdGenerator;
import de.listrong.da.tools.NewIDGener;
import de.listrong.da.metainfo.datamodel.MetaInfo;

import java.util.HashMap;
import java.io.File;

/* this class is for document individual in ABox */
public class FileSource implements WriteToABox {

	private int id;
	private String sourceURL;
	private SentenceList senteces;
    private MetaInfo metaInfo;

    /* constructor */
	public FileSource(Document doc, MetaInfo metainfo) {
		this.id = NewIDGener.newId(OntologyClasses.DOCUMENT);
                // IdGenerator.getInstance().newId(OntologyClasses.DOCUMENT);
		this.sourceURL = doc.getSourceUrl().toString();
        this.metaInfo = metainfo;
		this.senteces = null;
	}

    /* getter and setter methodes*/
	public int getId() {
		return id;
	}

//	public void setId(int id) {
//		this.id = id;
//	}

	public String getSourceURL() {
		return sourceURL;
	}

	public void setSourceURL(String sourceURL) {
		this.sourceURL = sourceURL;
	}

	public SentenceList getSenteces() {
		return senteces;
	}

	public void setSenteces(SentenceList senteces) {
		this.senteces = senteces;
	}

    /* overrides methodes */   
	@Override
	public Individual toOntIndiviual(OntModel tbox, OntModel abox) {
		String tBoxDefaultNS = tbox.getNsPrefixURI("");
		String aBoxNS = abox.getNsPrefixURI("");
		OntClass docClass = tbox.getOntClass(tBoxDefaultNS + "Document");
		Individual ind0 = abox.createIndividual(aBoxNS + "DOC-" + this.getId(),
				docClass);
		DatatypeProperty prop = tbox.getDatatypeProperty(tBoxDefaultNS + "sourceURL");
		ind0.addProperty(prop, this.getSourceURL());

        this.metaInfo.wirtToAbox(tbox, abox, ind0);

		return ind0;
	}

    @Override
	public String toString() {
		return "Document: id=" + this.id + ", sourceURL=" + this.sourceURL;
	}
	
}
